var Code = {
	bindEvent: function (){
		$(".list-table-body").on('click', '.table-operation', this.Operation);
	},
	Operation: function() {
		var _this = $(this),
		command = _this.attr("data-command"),
		args = _this.attr("data-command-args");
		if( command == 'modify' ) Code.Modify(_this, args);
		if( command == 'remove' ) Code.Remove(_this, args);
	},
	State: function(_this, args) {
		var _self = this;
		
	},
	Modify: function(_this, args) {
		var _self = this;
		PopModel.openFrame('/Code/edit?id=' +  args);
	},
	Remove: function(_this, args) {
		var _self = this;
		layer.confirm('您确定要删除当前代码位?', {
		  btn: ['确定','取消']
		}, function(){
			$.post("/Code/delete", {'id':args}, function(data){
				if(data.status == 'success') {
					_this.parents('tr').remove();
					layer.msg(data.msg, {icon: 1});
				} else {
					layer.msg(data.msg, {icon: 5});
				}
				return false;
			});
		});
	}
};

$(function(){
	Code.bindEvent();
});